package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.BindTeachplanMediaDto;
import com.xuecheng.content.model.dto.SaveTeachplanDto;
import com.xuecheng.content.model.dto.TeachplanDto;
import com.xuecheng.content.service.TeachplanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 课程计划管理
 * @author Tang
 * @version 1.0
 * @date 2023/12/26 21:09
 */
@Slf4j
@Api(value = "课程计划接口", tags = "课程计划接口")
@RestController
@RequestMapping("/teachplan")
public class TeachplanController {
    private final TeachplanService teachplanService;
    public TeachplanController(TeachplanService teachplanService) {
        this.teachplanService = teachplanService;
    }

    @ApiOperation(value = "课程计划查询接口")
    @GetMapping("/{courseId}/tree-nodes")
    public List<TeachplanDto> selectTeachplanNodes(@PathVariable Long courseId) {
        return teachplanService.selectTeachplanNodes(courseId);
    }

    @ApiOperation(value = "修改课程计划接口")
    @PostMapping
    public void updateTeachplan(@RequestBody SaveTeachplanDto saveTeachplanDto) {
        teachplanService.updateTeachplan(saveTeachplanDto);
    }

    @ApiOperation(value = "删除课程章节接口")
    @DeleteMapping("/{id}")
    public void deleteTeachplan(@PathVariable Long id) {
        teachplanService.deleteTeachplan(id);
    }

    @ApiOperation(value = "章节上移")
    @PostMapping("/moveup/{id}")
    public void moveup(@PathVariable Long id) {
        teachplanService.moveup(id);
    }

    @ApiOperation(value = "章节下移")
    @PostMapping("/movedown/{id}")
    public void movedown(@PathVariable Long id) {
        teachplanService.movedown(id);
    }

    @ApiOperation(value = "绑定媒资")
    @PostMapping("/association/media")
    public void bindMedia(@RequestBody BindTeachplanMediaDto bindTeachplanMediaDto) {
        teachplanService.bindMedia(bindTeachplanMediaDto);
    }
}
